package com.bidevalution.business.impl;

import com.bidevalution.business.service.BeSectionEvalutionResultService;
import com.bidevalution.dao.entity.BeSectionEvalutionResult;
import com.bidevalution.dao.entity.BeSectionParticipant;
import com.bidevalution.dao.mapper.BeSectionEvalutionResultMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qtp.core.model.Paging;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenh@glodon.com
 * @date 2019-05-15 11:32
 */
@Service
public class BeSectionEvalutionResultServiceImpl  implements BeSectionEvalutionResultService {

    @Autowired
    private BeSectionEvalutionResultMapper beSectionEvalutionResultMapper;
    /**
     * 获取评标结果列表
     *
     * @param sectionId       标段Id
     * @param participantName 投标单位名称
     * @param page            分页参数
     * @param rp              分页参数
     * @return
     * @throws Exception
     */
    @Override
    public Paging<List<BeSectionEvalutionResult>> getEvalutionResultList(String sectionId, String participantName, int page, int rp) throws Exception {
        //获取第二个数据源
        //获取分页参数
        Page<BeSectionParticipant> evalutionResultPage = PageHelper.startPage(page, rp);
        if(StringUtils.isNotBlank(participantName)){
            participantName = "%" + participantName + "%";
        } else {
            participantName = null;
        }
        List<BeSectionEvalutionResult> list = beSectionEvalutionResultMapper.getEvalutionResultList(sectionId, participantName);
        return new Paging(evalutionResultPage.getTotal(), list);
    }
}
